home *** CD-ROM | disk | FTP | other *** search
- #!/bin/sh
-
- # Ask user a permission
- cat <<EOF > /tmp/tmpmsg
- Do you want to setup a swap file ?
-
- The use of disk space as virtual memory is
- recommended if you have less than 16 Mb of memory.
-
- EOF
- dialog --title "SETUP SWAPSPACE" --yesno "`cat /tmp/tmpmsg`" 8 70 2> /tmp/SetQuery
- if [ $? != 0 ]; then
- exit 0;
- fi
-
- rm /tmp/tmpmsg /tmp/SetQuery
-
- # Setup swap space:
- /sbin/swapoff /dev/swapfile
- while [ "$SWAPSIZE" = "" ]; do
- DF=`df /dev`
- cat << EOF > /tmp/tmpmsg
- This is how much you have disk space:
- $DF
-
- How big swap file would you like to create?
-
- To give you an idea, you will specify a number such as 4096 if
- you want to use 4 megabytes of your DOS partition for a swap
- file. Assuming you have 4 megabytes of RAM, you will need a swap
- file of size 4096 to run X. I recommend 8192 for full use.
-
- Enter swap file size:
- EOF
- dialog --title "ENTER SIZE OF SWAPFILE" --inputbox "`cat /tmp/tmpmsg`" 20 70 \
- 2> /tmp/SeSSize
- if [ $? = 1 -o $? = 255 ]; then
- rm -f /tmp/SeSSize /tmp/tmpmsg
- exit
- fi
- SWAPSIZE="`cat /tmp/SeSSize`"
- rm -f /tmp/SeSSize /tmp/tmpmsg
- done
-
- dialog --title "CREATING SWAPFILE" --infobox "\n\
- Creating a ${SWAPSIZE}K swapfile in your /dev directory.\n\
- " 5 70
-
- dd if=/dev/zero of=/dev/swapfile bs=1024 count=$SWAPSIZE
- sync
- if [ ! $? = 0 ]; then
- sleep 5
- dialog --title "WHOOOOOPS" --msgbox "\n\
- Whoooops. I think there was an error there.\n\
- You'll probably have to reboot and try again, but\n\
- you might want to continue anyway.\n\
- \n\
- Press enter to continue. You may see a whole bunch of errors.\n\
- \n\
- Try not to look.\n\
- " 12 70
-
- sleep 15
- fi
-
- dialog --title "ACTIVATING SWAP" --infobox "\n\
- Running mkswap on the new swapfile and\n\
- activating swap partition\n\
- " 6 70
-
- mkswap /dev/swapfile $SWAPSIZE
- sync
- swapon /dev/swapfile
- if fgrep "/dev/swapfile" /etc/fstab > /dev/null 2>&1
- then
- :
- else
- echo "/dev/swapfile swap swap defaults" >> /etc/fstab
- echo "swapon /dev/swapfile" >> /etc/rc.d/rc.S
- fi
-
- sleep 5
-
- MEM=`/bin/free`
- dialog --title "MEMORY STATUS" --msgbox "\n\
- $MEM\n\
- You should see your swapspace indicated on the table above.\n\
- " 10 70
-
-